home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7088 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: postoffice.ptd.net!markgray
  2. From: markgray@postoffice.ptd.net (Mark T. Gray)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Is it possible to have one Makefile for several compilers?
  5. Date: 18 Feb 1996 17:03:55 GMT
  6. Organization: Entropy
  7. Message-ID: <4g7m5r$ih5@ns2.ptd.net>
  8. References: <31249363.1664@ivab.se>
  9. NNTP-Posting-Host: cs1-02.spa.ptd.net
  10.  
  11. In article <31249363.1664@ivab.se>, Goran Wireen  <Goran_Wireen@ivab.se> wrote:
  12. >I would like to use the same Makefile for different compilers 
  13. >(Gnu C/C++, Unix cc, CXX). I was hoping that I easily could 
  14. >select compiler by calling e.g:
  15. >
  16. >  make gcc all
  17. >
  18. >and by using a Makefile that looks something like this:
  19. >
  20. >  # Default compiler is cc
  21. >  CC = cc
  22. [snip]
  23. >
  24. >  all:
  25. >    $(CC) $(CFLAGS_AND_STUFF) $(SOURCES) ...
  26. >
  27. >But as you can assign macros in the command lines below cxx: and 
  28. >gcc: this won't work.
  29. >
  30. sure won't
  31.  
  32. >Does anybody have any idea how I can select compiler in a simple 
  33. >way?
  34.  
  35. you can override variables on the command line:
  36.  
  37. ie  make all CC=gcc
  38.  
  39.  
  40. quoting from info for GNU make:
  41.  
  42. Overriding Variables
  43. ====================
  44.  
  45.    An argument that contains = specifies the value of a variable:
  46. V=X sets the value of the variable V to X.  If you specify a value in
  47. this way, all ordinary assignments of the same variable in the makefile
  48. are ignored; we say they have been "overridden" by the command line
  49. argument.
  50.  
  51. (end quote)
  52.  
  53. Hope this helps.
  54.